import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Hang {
    public static void main(String[] args) throws IOException {
        FileInputStream f = new FileInputStream("C:\\Users\\my\\Desktop\\JAVA\\JAVA作业\\test.txt");
        BufferedReader dr = new BufferedReader(new InputStreamReader(f));
        String line = dr.readLine();
        long estimatedTime1 = System.nanoTime();
        int count=0;
        while (line != null) {
            System.out.println(line);
            line = dr.readLine();
            count++;
        }
        long estimatedTime2 = System.nanoTime();
        int time1= (int) (estimatedTime2-estimatedTime1);
        System.out.println("有"+count+"行:耗时"+time1+"毫秒。");
        long estimatedTime3 = System.nanoTime();
        dr.readLine();
        long estimatedTime4 = System.nanoTime();
        int time2= (int) (estimatedTime4-estimatedTime3);
        System.out.println("有"+dr.readLine()+"行:耗时"+time2+"毫秒。");
    }
}
